<?php
/* --------------------------------------------------------------
   PropertiesBasket.php 2009-12-14 gambio
   Gambio GmbH
   http://www.gambio.de
   Copyright (c) 2009 Gambio GmbH
   Released under the GNU General Public License (Version 2)
   [http://www.gnu.org/licenses/gpl-2.0.html]
   --------------------------------------------------------------
*/


class PropertiesBasket 
{
	var $v_combis_selections_array = array();
	
	function PropertiesBasket() 
	{
	}
	
	function add_combis_selection($p_products_properties_combis_id)
	{
		$c_combis_id = (int)$p_products_properties_combis_id;
		
		# add only, if combis_id doesn't exist yet
		if(in_array($c_combis_id, $this->v_combis_selections_array)) 
		{
			$this->v_combis_selections_array[] = (int)$p_products_properties_combis_id;
			return true;
		}
		return false;
	}
	
	
	function get_combis_data_object($p_products_properties_combis_id)
	{
		$c_products_properties_combis_id = (int)$p_products_properties_combis_id;
		$coo_data_group = new GMDataObjectGroup('products_properties_combis', array('products_properties_combis_id' => $c_products_properties_combis_id));
		
		$t_data_object_array = $coo_data_group->get_data_objects_array();
		if(sizeof($t_data_object_array) == 0)
		{
			# combis_id not found
			return false;
		}
		
		if(sizeof($t_data_object_array) > 1) 
		{
			# result count must not > 1
			trigger_error('get_combis_data(): $sizeof($t_data_object_array) > 1', E_USER_WARNING);
		}
		
		# return single data object
		$t_output_value = $t_data_object_array[0];
		
		return $t_output_value;
	}
	
	function get_combis_plus_price($p_products_properties_combis_id)
	{
		$t_output_value = 0;
		$coo_data = $this->get_combis_data_object($p_products_properties_combis_id);
		
		if($coo_data != false) {
			if($coo_data->get_data_value('combi_price_type') == 'plus') {
				$t_output_value = $coo_data->get_data_value('combi_price');
			}
		}
		return $t_output_value;
	}

	function get_combis_product_price($p_products_properties_combis_id)
	{
		$t_output_value = 0;
		$coo_data = $this->get_combis_data_object($p_products_properties_combis_id);
		
		if($coo_data != false) {
			if($coo_data->get_data_value('combi_price_type') == 'fix') {
				$t_output_value = $coo_data->get_data_value('combi_price');
			}
		}
		return $t_output_value;
	}
	
	
	function save()
	{
		/*
		$coo_properties_do = new GMDataObject('properties');
		$t_properties_id = 0;
		
		if($t_insert_mode) {
			# set to false for an insert
			$coo_properties_do->set_keys(array('properties_id' => false));
		} 
		else {
			# using a given key will cause an update
			$t_properties_id = (int)$p_data_array['properties_id']; 
			$coo_properties_do->set_keys(array('properties_id' => $t_properties_id));
		}
		$coo_properties_do->set_data_value('sort_order', $p_data_array['properties_sort_order']);
		$t_insert_id = $coo_properties_do->save_body_data();
		*/
	}
	
	
	
	
}

?>